{# layout.html.twig #}
{# Base layout #}

{% if app['combodo.current_user'] is defined and app['combodo.current_user'] is not null %}
	{% set bUserConnected = true %}
	{% set sUserFullname = app['combodo.current_user'].Get('first_name') ~ ' ' ~ app['combodo.current_user'].Get('last_name') %}
	{% set sUserEmail = app['combodo.current_user'].Get('email') %}
	{% set sUserPhotoUrl = app['combodo.current_contact.photo_url'] %}
{% else %}
	{% set bUserConnected = false %}
	{% set sUserFullname = '' %}
	{% set sUserEmail = '' %}
	{% set sUserPhotoUrl = app['combodo.portal.base.absolute_url'] ~ 'img/user-profile-default-256px.png' %}
{% endif %}

<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	{# This block can be used to add your own meta tags by extending the default template #}
	{% block pPageExtraMetas %}
	{% endblock %}
	<title>{% block pPageTitle %}{% if sPageTitle is defined and sPageTitle is not null %}{{ sPageTitle }} - {{ constant('ITOP_APPLICATION_SHORT') }}{% else %}{{ 'Page:DefaultTitle'|dict_format(constant('ITOP_APPLICATION_SHORT')) }}{% endif %}{% endblock %}</title>
	<link rel="shortcut icon" href="{{ app['combodo.absolute_url'] ~ 'images/favicon.ico'|add_itop_version }}" />

	{% block pPageStylesheets %}
		{# First bootstrap core, lib themes, then bootstrap theme, portal adjustements #}
		<link href="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/bootstrap/css/bootstrap.min.css'|add_itop_version }}" rel="stylesheet">
		{# - Bootstrap Datetime picker #}
		<link href="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css'|add_itop_version }}" rel="stylesheet">
		{# - Datatables #}
		<link href="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/datatables/css/dataTables.bootstrap.min.css'|add_itop_version }}" rel="stylesheet">
		<link href="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/datatables/css/fixedHeader.bootstrap.min.css'|add_itop_version }}" rel="stylesheet">
		<link href="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/datatables/css/responsive.bootstrap.min.css'|add_itop_version }}" rel="stylesheet">
		<link href="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/datatables/css/scroller.bootstrap.min.css'|add_itop_version }}" rel="stylesheet">
		<link href="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/datatables/css/select.bootstrap.min.css'|add_itop_version }}" rel="stylesheet">
		<link href="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/datatables/css/select.dataTables.min.css'|add_itop_version }}" rel="stylesheet">
        {# - Font OpenSans #}
		<link href="{{ app['combodo.absolute_url'] ~ 'css/font-open-sans/font-open-sans.css'|add_itop_version }}" rel="stylesheet">
        {# - Font Combodo #}
		<link href="{{ app['combodo.absolute_url'] ~ 'css/font-combodo/font-combodo.css'|add_itop_version }}" rel="stylesheet">
        {# - Font awesome #}
		<link href="{{ app['combodo.absolute_url'] ~ 'css/font-awesome/css/font-awesome.min.css'|add_itop_version }}" rel="stylesheet">
		{# - Misc libs #}
		<link href="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/typeahead/css/typeaheadjs.bootstrap.css'|add_itop_version }}" rel="stylesheet">
		<link href="{{ app['combodo.absolute_url'] ~ 'css/magnific-popup.css'|add_itop_version }}" rel="stylesheet">
		<link href="{{ app['combodo.absolute_url'] ~ 'css/c3.min.css'|add_itop_version }}" rel="stylesheet">
		{# - Bootstrap theme #}
		<link href="{{ app['combodo.portal.instance.conf'].properties.themes.bootstrap|add_itop_version }}" rel="stylesheet" id="css_bootstrap_theme">
		{# - Portal adjustments for BS theme #}
		<link href="{{ app['combodo.portal.instance.conf'].properties.themes.portal|add_itop_version }}" rel="stylesheet" id="css_portal">
		{# UI Extensions CSS, in an undefined order #}
        {% if app['combodo.portal.instance.conf'].ui_extensions.css_files is defined %}
            {% for css_file in app['combodo.portal.instance.conf'].ui_extensions.css_files %}
				<link href="{{ css_file|add_itop_version }}" rel="stylesheet">
            {% endfor %}
        {% endif %}
		{# Custom CSS that is supposed to do adjustments to the portal #}
		{% if app['combodo.portal.instance.conf'].properties.themes.custom is defined %}
			<link href="{{ app['combodo.portal.instance.conf'].properties.themes.custom|add_itop_version }}" rel="stylesheet">
		{% endif %}
		{# Others CSS that will come after the theme/portal/custom, in an undefined order #}
		{% if app['combodo.portal.instance.conf'].properties.themes.others is defined %}
			{% for theme in app['combodo.portal.instance.conf'].properties.themes.others %}
				<link href="{{ theme|add_itop_version }}" rel="stylesheet">
			{% endfor %}
		{% endif %}
	{% endblock %}

	{% block pStyleinline %}
        {# UI Extensions inline CSS #}
        {% if app['combodo.portal.instance.conf'].ui_extensions.css_inline is not null %}
			<style>
				{{ app['combodo.portal.instance.conf'].ui_extensions.css_inline|raw }}
			</style>
        {% endif %}
	{% endblock %}

	{% block pPageScripts %}
		<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/jquery-1.12.4.min.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/jquery-migrate-1.4.1.min.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/jquery-ui-1.11.4.custom.min.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/jquery.magnific-popup.min.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/jquery.iframe-transport.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/jquery.fileupload.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/d3.min.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/c3.min.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/bootstrap/js/bootstrap.min.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/latinise/latinise.min.js'|add_itop_version }}"></script>
		{# Visible.js to check if an element is visible on screen #}
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/jquery-visible/js/jquery.visible.min.js'|add_itop_version }}"></script>
        {# Base64.js #}
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/jquery-base64/js/jquery.base64.min.js'|add_itop_version }}"></script>
		{# Moment.js #}
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/moment/js/moment.min.js'|add_itop_version }}"></script>
		{# Datatables #}
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/datatables/js/jquery.dataTables.min.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/datatables/js/dataTables.bootstrap.min.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/datatables/js/dataTables.fixedHeader.min.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/datatables/js/dataTables.responsive.min.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/datatables/js/dataTables.scroller.min.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/datatables/js/dataTables.select.min.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/datatables/js/datetime-moment.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'js/dataTables.accentNeutraliseForFilter.js'|add_itop_version }}"></script>
        {# Export for Datatables #}
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'js/export.js'|add_itop_version }}"></script>
		{# CKEditor files for HTML WYSIWYG #}
		<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/ckeditor/ckeditor.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/ckeditor/adapters/jquery.js'|add_itop_version }}"></script>
		{# Date-time picker for Bootstrap #}
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'|add_itop_version }}"></script>
		{# Typeahead files for autocomplete #}
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/typeahead/js/typeahead.bundle.min.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/handlebars/js/handlebars.min-768ddbd.js'|add_itop_version }}"></script>
		{# Form files #}
		<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/form_handler.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/form_field.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/subform_field.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/field_set.js'|add_itop_version }}"></script>
		{# Form files for portal #}
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'js/portal_form_handler.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'js/portal_form_field.js'|add_itop_version }}"></script>
		<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'js/portal_form_field_html.js'|add_itop_version }}"></script>
        {# UI Extensions JS, in an undefined order #}
        {% if app['combodo.portal.instance.conf'].ui_extensions.js_files is defined %}
			{% for js_file in app['combodo.portal.instance.conf'].ui_extensions.js_files %}
				<script type="text/javascript" src="{{ js_file|add_itop_version }}"></script>
			{% endfor %}
        {% endif %}
		<script type="text/javascript">
			$(document).ready(function() {
				$('.tile.tile_badge[data-toggle="tooltip"]').tooltip({'html': true});
			});
		</script>
	{% endblock %}
</head>
<body class="{% block pPageBodyClass %}{% endblock %}">
	{% block pPageBodyWrapper %}
		{% block pEnvBannerWrapper %}
			{% if app['combodo.current_environment'] != 'production' %}
				<div id="envbanner" class="alert alert-danger" role="alert">
					{{ 'Portal:EnvironmentBanner:Title'|dict_format( app['combodo.current_environment']|upper )|raw }}
					<button type="button" onclick="window;location.href='{{ app['url_generator'].generate('p_home', {'switch_env': 'production'}) }}'">
						{{ 'Portal:EnvironmentBanner:GoToProduction'|dict_s|raw }}
					</button>
				</div>
			{% endif %}
		{% endblock %}
		
		{% block pNavigationWrapper %}
			{# Topbar navigation menu for mobile screens #}
			{% block pNavigationTopMenuWrapper %}
				<nav class="navbar navbar-fixed-top navbar-default visible-xs" id="topbar" role="navigation">
					<div class="container-fluid">
						<div class="navbar-header">
							<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
								<span class="icon-bar"></span>
								<span class="icon-bar"></span>
								<span class="icon-bar"></span>
							</button>
							{% block pNavigationTopMenuLogo %}
								<a class="navbar-brand pull-right" href="{{ app.url_generator.generate('p_home') }}">
									{% if app['combodo.portal.instance.conf'].properties.logo is not null %}
										<img src="{{ app['combodo.portal.instance.conf'].properties.logo }}" alt="{{ app['combodo.portal.instance.conf'].properties.name|dict_s }}" />
									{% else %}
										iTop
									{% endif %}
								</a>
							{% endblock %}
							<p class="navbar-text">
								<a class="navbar-link user_infos" href="{{ app.url_generator.generate('p_user_profile_brick') }}">
									<span class="user_photo" style="background-image: url('{{ sUserPhotoUrl }}');"></span>
									<span class="user_fullname">{{ sUserFullname }}</span>
								</a>
							</p>
						</div>
						<div class="collapse navbar-collapse" id="navbar">
							<ul class="nav navbar-nav">
								{% block pNavigationTopBricks %}
									<li class="{% if oBrick is not defined %}active{% endif %}">
										<a href="{{ app.url_generator.generate('p_home') }}">
											<span class="brick_icon fa fa-home fa-2x"></span>
											{{ 'Page:Home'|dict_s }}
										</a>
									</li>
									{% for brick in app['combodo.portal.instance.conf'].bricks_ordering.navigation_menu %}
										{% if brick.GetActive and brick.GetVisibleNavigationMenu and brick.GetRouteName is not null %}
											<li class="{% if oBrick is defined and brick.id == oBrick.id %}active{% endif %}">
												<a href="{{ app.url_generator.generate(brick.GetRouteName, {sBrickId: brick.GetId}) }}{% if app['combodo.portal.instance.routes'][brick.GetRouteName]['hash'] is defined %}#{{ app['combodo.portal.instance.routes'][brick.GetRouteName]['hash'] }}{% endif %}" {% if app['combodo.portal.instance.routes'][brick.GetRouteName]['navigation_menu_attr'] is defined %}{% for key, value in app['combodo.portal.instance.routes'][brick.GetRouteName]['navigation_menu_attr'] %} {{ key }}="{{ value }}"{% endfor %}{% endif %} {% if brick.GetModal %}data-toggle="modal" data-target="#modal-for-all"{% endif %}>
													<span class="brick_icon {{ brick.GetDecorationClassNavigationMenu }}"></span>
													{{ brick.GetTitleNavigationMenu|dict_s }}
												</a>
											</li>
										{% endif %}
									{% endfor %}
								{% endblock %}
								{% if bUserConnected %}
									<li role="separator" class="divider"></li>
									<li><a href="{{ app.url_generator.generate('p_user_profile_brick') }}"><span class="brick_icon fa fa-user fa-2x fa-fw"></span>{{ 'Brick:Portal:UserProfile:Navigation:Dropdown:MyProfil'|dict_s }}</a></li>
									{% for aPortal in app['combodo.portal.instance.conf'].portals %}
										{% if aPortal.id != app['combodo.portal.instance.conf'].properties.id %}
											{% set sIconClass = (aPortal.id == 'backoffice') ? 'fa-list-alt' : 'fa-external-link' %}
											<li><a href="{{ aPortal.url }}" target="_blank"><span class="brick_icon fa {{ sIconClass }} fa-2x fa-fw"></span>{{ aPortal.label|dict_s }}</a></li>
										{% endif %}
									{% endfor %}
									{# We display the separator only if the user has more then 1 portal. Meaning default portal + console or several portal at least #}
									{% if app['combodo.portal.instance.conf'].portals|length > 1 %}
										<li role="separator" class="divider"></li>
									{% endif %}
									<li><a href="{{ app['combodo.absolute_url'] }}pages/logoff.php"><span class="brick_icon fa fa-sign-out fa-2x fa-fw"></span>{{ 'Brick:Portal:UserProfile:Navigation:Dropdown:Logout'|dict_s }}</a></li>
								{% endif %}
							</ul>
						</div>

                        {% block pPageUIExtensionNavigationMenuTopbar %}
                            {% if app['combodo.portal.instance.conf'].ui_extensions.html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_NAVIGATION_MENU')] is defined %}
                                {{ app['combodo.portal.instance.conf'].ui_extensions.html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_NAVIGATION_MENU')]|raw }}
                            {% endif %}
                        {% endblock %}
					</div>
				</nav>
			{% endblock %}

			{# Sidebar navigation menu for normal screens #}
			{% block pNavigationSideMenuWrapper %}
				<nav class="navbar-default hidden-xs col-sm-3 col-md-2" id="sidebar" role="navigation">
					<div class="user_card bg-primary">
						<div class="user_photo" style="background-image: url('{{ sUserPhotoUrl }}');">
						</div>
						<div class="user_infos">
							<div class="user_fullname">{{ sUserFullname }}</div>
							<div class="user_email dropdown">
								<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="user_options">
									{{ sUserEmail }}
									<span class="caret"></span>
								</a>
								<ul class="dropdown-menu user_options" aria-labelledby="user_options">
									<li><a href="{{ app.url_generator.generate('p_user_profile_brick') }}"><span class="brick_icon fa fa-user fa-lg fa-fw"></span>{{ 'Brick:Portal:UserProfile:Navigation:Dropdown:MyProfil'|dict_s }}</a></li>
									{% for aPortal in app['combodo.portal.instance.conf'].portals %}
										{% if aPortal.id != app['combodo.portal.instance.conf'].properties.id %}
											{% set sGlyphiconClass = (aPortal.id == 'backoffice') ? 'fa-list-alt' : 'fa-external-link' %}
											<li><a href="{{ aPortal.url }}" {% if app['combodo.portal.instance.conf'].properties.allowed_portals.opening_mode == 'tab' %}target="_blank"{% endif %} title="{{ aPortal.label|dict_s }}"><span class="brick_icon fa {{ sGlyphiconClass }} fa-lg fa-fw"></span>{{ aPortal.label|dict_s }}</a></li>
										{% endif %}
									{% endfor %}
									{# We display the separator only if the user has more then 1 portal. Meaning default portal + console or several portal at least #}
									{% if app['combodo.portal.instance.conf'].portals|length > 1 %}
										<li role="separator" class="divider"></li>
									{% endif %}
									<li><a href="{{ app['combodo.absolute_url'] }}pages/logoff.php"><span class="brick_icon fa fa-sign-out fa-lg fa-fw"></span>{{ 'Brick:Portal:UserProfile:Navigation:Dropdown:Logout'|dict_s }}</a></li>
								</ul>
							</div>
						</div>
					</div>
					<div class="menu">
						{% block pNavigationSideMenu %}
							<ul class="nav navbar-nav">
								<li class="{% if oBrick is not defined %}active{% endif %}">
									<a href="{{ app.url_generator.generate('p_home') }}">
										<span class="brick_icon fa fa-home fa-2x"></span>
										{{ 'Page:Home'|dict_s }}
									</a>
								</li>
								{% for brick in app['combodo.portal.instance.conf'].bricks_ordering.navigation_menu %}
									{% if brick.GetActive and brick.GetVisibleNavigationMenu and brick.GetRouteName is not null %}
										<li class="{% if oBrick is defined and brick.id == oBrick.id %}active{% endif %}">
											<a href="{{ app.url_generator.generate(brick.GetRouteName, {sBrickId: brick.GetId}) }}{% if app['combodo.portal.instance.routes'][brick.GetRouteName]['hash'] is defined %}#{{ app['combodo.portal.instance.routes'][brick.GetRouteName]['hash'] }}{% endif %}" {% if app['combodo.portal.instance.routes'][brick.GetRouteName]['navigation_menu_attr'] is defined %}{% for key, value in app['combodo.portal.instance.routes'][brick.GetRouteName]['navigation_menu_attr'] %} {{ key }}="{{ value }}"{% endfor %}{% endif %} {% if brick.GetModal %}data-toggle="modal" data-target="#modal-for-all"{% endif %}>
												<span class="brick_icon {{ brick.GetDecorationClassNavigationMenu }}"></span>
												{{ brick.GetTitleNavigationMenu|dict_s }}
											</a>
										</li>
									{% endif %}
								{% endfor %}
							</ul>
						{% endblock %}
					</div>

                    {% block pPageUIExtensionNavigationMenuSidebar %}
                        {% if app['combodo.portal.instance.conf'].ui_extensions.html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_NAVIGATION_MENU')] is defined %}
                            {{ app['combodo.portal.instance.conf'].ui_extensions.html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_NAVIGATION_MENU')]|raw }}
                        {% endif %}
                    {% endblock %}

					{% if app['combodo.portal.instance.conf'].properties.logo is not null %}
						<div class="logo">
							{% block pNavigationSideMenuLogo %}
								{# This is a debug helper to know in which screen size we are #}
								{% if app['debug'] %}
									<div style="position: fixed; bottom: 0px; left: 0px; z-index: 9999;">Debug : Taille <span class="hidden-sm hidden-md hidden-lg">XS</span><span class="hidden-xs hidden-md hidden-lg">SM</span><span class="hidden-xs hidden-sm hidden-lg">MD</span><span class="hidden-xs hidden-sm hidden-md">LG</span></div>
								{% endif %}
								<a href="{{ app.url_generator.generate('p_home') }}" title="{{ app['combodo.portal.instance.conf'].properties.name|dict_s }}">
									<img src="{{ app['combodo.portal.instance.conf'].properties.logo }}" alt="{{ app['combodo.portal.instance.conf'].properties.name|dict_s }}" />
								</a>
							{% endblock %}
						</div>
					{% endif %}
				</nav>
			{% endblock %}
		{% endblock %}
		
		{% block pMainWrapper %}
		<div class="container-fluid" id="main-wrapper">
			<div class="row">
				<div class="col-xs-12 col-sm-9 col-md-10 col-sm-offset-3 col-md-offset-2">
					
					<section class="row" id="main-header">
						{% block pMainHeader %}
						{% endblock %}
					</section>

					<section class="row" id="main-content">
						{% block pMainContent %}
						{% endblock %}
					</section>
				</div>
			</div>

			{% block pPageUIExtensionMainContent %}
                {% if app['combodo.portal.instance.conf'].ui_extensions.html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_MAIN_CONTENT')] is defined %}
                    {{ app['combodo.portal.instance.conf'].ui_extensions.html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_MAIN_CONTENT')]|raw }}
                {% endif %}
			{% endblock %}
		</div>
		{% endblock %}
		
		<footer id="footer-wrapper">
			{% block pPageFooter%}
				{#<a href="http://www.combodo.com">iTop &copy; {{ "now"|date('Y') }}</a>#}
			{% endblock %}
		</footer>
	
		{% block pModalForAllWrapper %}
			<div class="modal fade" id="modal-for-all" role="dialog">
				<div class="modal-dialog modal-lg" role="document">
					<div class="modal-content">
						{% include 'itop-portal-base/portal/src/views/helpers/loader.html.twig' %}
					</div>
				</div>
			</div>
		{% endblock %}
		{% block pModalForAlert %}
			<div class="modal fade" id="modal-for-alert" role="dialog">
				<div class="modal-dialog" role="document">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-label="{{ 'Portal:Button:Close'|dict_s }}"><span aria-hidden="true">&times;</span></button>
							<h4 class="modal-title"></h4>
						</div>
						<div class="modal-body">
							<div class="alert">
							</div>
							<div class="text-right">
								<button type="button" class="btn btn-primary" data-dismiss="modal">{{ 'Portal:Button:Close'|dict_s }}</button>
							</div>
						</div>
					</div>
				</div>
			</div>
		{% endblock %}

		{% block pPageOverlay %}
			<div id="page_overlay" class="global_overlay">
				<div class="overlay_content">
					{% include 'itop-portal-base/portal/src/views/helpers/loader.html.twig' %}
				</div>
			</div>
		{% endblock %}

		{% block pPageUIExtensionBody %}
			{% if app['combodo.portal.instance.conf'].ui_extensions.html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_BODY')] is defined %}
				{{ app['combodo.portal.instance.conf'].ui_extensions.html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_BODY')]|raw }}
			{% endif %}
		{% endblock %}
	{% endblock %}
	
	{% block pPageLiveScripts %}
		<script type="text/javascript">
			{% block pPageLiveScriptHelpers %}
				// Helper to get the application root url
				var GetAbsoluteUrlAppRoot = function()
				{
					return '{{ app['combodo.absolute_url'] }}';
				};
				// Helper to add a parameter to an url
				var AddParameterToUrl = function(sUrl, sParamName, sParamValue)
				{
					sUrl += (sUrl.split('?')[1] ? '&':'?') + sParamName + '=' + sParamValue;
					return sUrl;
				};
				var GetContentLoaderTemplate = function()
				{
					return '<div class="content_loader"><div class="icon glyphicon glyphicon-refresh"></div><div class="message">{{ 'Page:PleaseWait'|dict_s }}</div></div>';
				}
				var ShowLoginDialog = function()
				{
                    var oModalElem = $('#modal-for-alert').clone();
                    oModalElem.attr('id', '');
                    oModalElem.find('.modal-content .modal-header .modal-title').html('{{ 'Error:HTTP:401'|dict_s|escape('js') }}');
                    oModalElem.find('.modal-content .modal-body .alert').addClass('alert-danger').html('{{ 'Portal:ErrorUserLoggedOut'|dict_s|escape('js') }}');

                    oModalElem.find('.modal-content .modal-body button').replaceWith( $('<button type="button" class="btn btn-primary" onclick="javascript:window.location.reload();">{{ 'UI:LogOff:ClickHereToLoginAgain'|dict_s|escape('js') }}</button>') );

                    oModalElem.appendTo('body');
                    oModalElem.modal('show');
				};
				var ShowErrorDialog = function(sBody, sTitle)
				{
				    if(sTitle === undefined)
					{
					    sTitle = '{{ 'Error:HTTP:500'|dict_s|escape('js') }}';
					}
				    if(sBody === undefined)
					{
                        sBody = '{{ 'Error:XHR:Fail'|dict_format(constant('ITOP_APPLICATION_SHORT'))|escape('js') }}';
					}
					var oModalElem = $('#modal-for-alert');
                    oModalElem.find('.modal-content .modal-header .modal-title').html(sTitle);
                    oModalElem.find('.modal-content .modal-body .alert').addClass('alert-danger').html(sBody);
                    oModalElem.modal('show');
				};
			{% endblock %}
			
			$(document).ready(function(){
				{% block pPageReadyScripts %}
					// Hack to enable a same modal to load content from different urls
					$('body').on('hidden.bs.modal', '.modal#modal-for-all', function () {
						$(this).removeData('bs.modal');
						$(this).find('.modal-content').html(GetContentLoaderTemplate());
					});
					// Hack to enable multiple modals by making sure the .modal-open class is set to the <body> when there is at least one modal open left
					$('body').on('hidden.bs.modal', function () {
						if($('.modal.in').length > 0)
						{
							$('body').addClass('modal-open');
						}
					});
					// Hide tooltips when a modal is opening, otherwise it might be overlapping it
					$('body').on('show.bs.modal', function () {
						$(this).find('.tooltip.in').tooltip('hide');
					});
					// Display a error message on modal if the content could not be loaded.
					// Note : As of now, we can't display a more detailled message based on the response because Bootstrap doesn't pass response data with the loaded event.
					$('body').on('loaded.bs.modal', function (oEvent) {
						var sModalContent = $(oEvent.target).find('.modal-content').html();
						
						if( (sModalContent === '') || (sModalContent.replace(/[\n\r\t]+/g, '') === GetContentLoaderTemplate()) )
						{
							$(oEvent.target).modal('hide');
						}
					});

					// Handle AJAX errors (exceptions (500), logout (401), ...)
					$(document).ajaxError(function(oEvent, oXHR, oSettings, sError){
					    if(oXHR.status === 401)
						{
						    ShowLoginDialog();
						}
                        else if(oXHR.status === 404)
                        {
                            ShowErrorDialog('{{ 'UI:ObjectDoesNotExist'|dict_s|escape('js') }}', '{{ 'Error:HTTP:404'|dict_s|escape('js') }}');
                        }
                        else
                        {
                            ShowErrorDialog();
                        }
					});
				{% endblock %}
			});
		</script>
	{% endblock %}

	{% block pPageExtensionsScripts %}
        {# UI Extensions inline JS #}
        {% if app['combodo.portal.instance.conf'].ui_extensions.js_inline is not null %}
			<script type="text/javascript">
				{{ app['combodo.portal.instance.conf'].ui_extensions.js_inline|raw }}
			</script>
        {% endif %}
	{% endblock %}
</body>
</html>